Skip to content

Conversation

@TerryTaoYY
Copy link
Contributor

Summary

Align LinkedCaseInsensitiveMap’s entrySet() view with the map’s case-insensitive key contract by making entrySet().contains(..) and entrySet().remove(..) perform case-insensitive key resolution.

Background

LinkedCaseInsensitiveMap provides case-insensitive behavior for containsKey/get/remove. However, entrySet() operations previously delegated to the backing map’s entry set, which performs case-sensitive key comparisons. As a result, entry-based operations could miss existing mappings when callers used different key casing.

Example

LinkedCaseInsensitiveMap<String> map = new LinkedCaseInsensitiveMap<>();
map.put("Key", "value");

assertThat(map.containsKey("KEY")).isTrue();
assertThat(map.entrySet()).contains(Map.entry("KEY", "value")); // previously failed
assertThat(map.entrySet().remove(Map.entry("key", "value"))).isTrue();
assertThat(map).isEmpty();

Changes

  • Implement case-insensitive key lookup for EntrySet.contains(Object) and EntrySet.remove(Object) via containsKey/get/remove
  • Preserve Map.Entry semantics by requiring value equality (using ObjectUtils.nullSafeEquals) before removing

Tests

  • ./gradlew :spring-core:test --tests org.springframework.util.LinkedCaseInsensitiveMapTests
  • ./gradlew :spring-core:test

Signed-off-by: Terry Tao <yueyang.tao@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 19, 2025
@bclozel bclozel self-assigned this Dec 20, 2025
@bclozel bclozel added the in: core Issues in core modules (aop, beans, core, context, expression) label Dec 20, 2025
bclozel pushed a commit that referenced this pull request Dec 23, 2025
See gh-36056

Signed-off-by: Terry Tao <yueyang.tao@gmail.com>
@bclozel bclozel closed this in 214cb2c Dec 23, 2025
@bclozel bclozel added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 23, 2025
@bclozel bclozel added this to the 7.0.3 milestone Dec 23, 2025
@bclozel
Copy link
Member

bclozel commented Dec 23, 2025

Thanks for your contribution @TerryTaoYY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants